package leetcode_core.service.impl;

import leetcode_core.dao.ClazzDAO;
import leetcode_core.dao.OrderDAO;
import leetcode_core.dao.impl.ClazzDAOImpl;
import leetcode_core.dao.impl.OrderDAOImpl;
import leetcode_core.domain.Order;
import leetcode_core.service.ClassService;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年01月07日 11:25
 */
public class ClassServiceImpl implements ClassService {
    private ClazzDAO clazzDAO = new ClazzDAOImpl();
    private OrderDAO orderDAO = new OrderDAOImpl();
    @Override
    public void choseLesson(String studentId, String classId) {
        //参数校验
        if(studentId == null || studentId.equals("") || classId == null || classId.equals("")){
            throw new RuntimeException("参数不能为空!");
        }
        Order order = new Order(null,studentId,classId);
        orderDAO.insertOrder(order);
        clazzDAO.updateClassStocks(order.getClassId());
    }
}
